//
//  TextViewController.m
//  Text
//
//  Created by dllo on 15/12/28.
//  Copyright © 2015年 HaiTeng. All rights reserved.
//

#import "TextViewController.h"
#import "CarouselFingure.h"
@interface TextViewController ()<CarouselFingureDelegate>
@property(nonatomic,strong)UIImage *image;
@end

@implementation TextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.view.backgroundColor = [UIColor yellowColor];
    [self setUtils];
}

- (void)setUtils
{
    //轮播图
    NSMutableArray *imagesArray = [NSMutableArray array];
    
 
    for (int i = 1; i < 7; i ++) {
       
      
        
        if (i == 1) {
            self.image = [UIImage imageNamed:@"04.png"];
        
        }else if (i == 6){
          self.image = [UIImage imageNamed:@"01.png"];
          
        }else{
          self.image = [UIImage imageNamed:[NSString stringWithFormat:@"0%d.png",i - 1]];
        }
    
        [imagesArray addObject:self.image];
    }
    //只需要,创建
    CarouselFingure * carouselFingure = [[CarouselFingure alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200)];
    //赋值
    carouselFingure.imagesArray = imagesArray;
//也可以设置代理,触发点击事件
    carouselFingure.delegate = self;
    //设置 下偏移量
    carouselFingure.scrollView.contentOffset = CGPointMake(carouselFingure.frame.size.width, 0);
    //定时器时长
//    carouselFingure.duration = 1.5; //默认, 2秒
    //就这么简单, 封装, 哈哈哈 (只支持,竖屏, 支持各种位置,各种大小. YES)
    [self.view addSubview:carouselFingure];
  
}
//代理(点击事件)
- (void)carouselFingureDidCarousel:(CarouselFingure *)carouselFingure atIndex:(NSUInteger)index{
    NSLog(@"%ld",(unsigned long)index);
}

@end
